package com.sise.itree.common.config;


import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author idea
 * @date 2019/4/28
 * @Version V1.0
 */
@Slf4j
public class ITreeConfig {

    public static String INDEX_PAGE;

    public static String NOT_FOUND_PAGE;

    public static String UNKOWN_EXCEPTION_PAGE;

    public static int PORT;

    public static String BASE_PATH;

    //公共应用类
    public static Class APPLICATION_CLASS;

    static {
        Properties properties = new Properties();
        InputStream in = ITreeConfig.class.getClassLoader().getResourceAsStream("config/itree-config.properties");
        try {
            properties.load(in);
            INDEX_PAGE = properties.getProperty("index.page");
            NOT_FOUND_PAGE = properties.getProperty("not.found.page");
            UNKOWN_EXCEPTION_PAGE = properties.getProperty("unkown.exception.page");
            if(properties.getProperty("server.port")!=null){
                PORT = Integer.parseInt(properties.getProperty("server.port"));
            }
            PORT=8080;
            BASE_PATH = properties.getProperty("base.path");
        } catch (IOException e) {
            log.error("[ITreeConfig]异常为{}", e);
        }
    }


    public ITreeConfig() {
        System.out.println("[ITreeConfig]server初始化静态资源文件");
    }

    public static void main(String[] args) {
        ITreeConfig iTreeConfig = new ITreeConfig();
    }


}
